package com.karst.webnotes.chapter03
{
	import flash.events.Event;
	
	import org.aswing.AsWingManager;
	import org.papervision3d.objects.DisplayObject3D;
	import org.papervision3d.objects.primitives.Sphere;
	import org.papervision3d.view.BasicView;
	
	internal class VerticesExample extends BasicView
	{
		public function VerticesExample()
		{
			super() ;
			AsWingManager.getStage().frameRate = 24 ;
			createView() ;
			startRendering() ;
		}
		
		private var num : uint = 0 ;
		private var do3d : DisplayObject3D = null ;
		private var parentSphere : Sphere = null ;
		private function createView() : void
		{
			if( do3d == null )
				do3d = new DisplayObject3D() ;
			scene.addChild( do3d ) ;
			
			if( parentSphere == null )
				parentSphere = new Sphere( null, 300, 10, 10 ) ;

			num = parentSphere.geometry.vertices.length ;
			for( var i : uint = 0 ;i < num ; i++ )
			{
				var childSphere : Sphere = new Sphere( null, 50, 5, 3 ) ;
				childSphere.x = parentSphere.geometry.vertices[i].x ;
				childSphere.y = parentSphere.geometry.vertices[i].y ;
				childSphere.z = parentSphere.geometry.vertices[i].z ;
				do3d.addChild( childSphere ) ;
			}
		}
		
		override protected function onRenderTick(event:Event=null):void
		{
			super.onRenderTick( event ) ;
			do3d.localRotationX-- ;
			do3d.localRotationY-- ;
		}
	}
}